﻿using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;

namespace TicTacToe.Opponents
{
    /// <summary>
    /// Finds all of the IOpponent classes marked with the OpponentAttribute class in this assembly
    /// </summary>
    public class OpponentCatalog
    {
        [ImportMany]
        public List<IOpponent> Opponents { get; set; }

        public OpponentCatalog()
        {
            var catalog = new AssemblyCatalog(GetType().Assembly);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);
        }
    }
}
